<?php require_once(BASEPATH.'application/controllers/validaciones.php');
//Cliente
class cambio extends validaciones {
	

	function cambio(){
		parent::Controller(); 
		$this->load->library("rapyd");
		$this->load->library('pi18n');
	}

	function index(){
		redirect("supervisor/cambio/filteredgrid");
	}
	function filteredgrid(){
		
		$this->rapyd->load("datafilter","datagrid2");
		$this->rapyd->uri->keep_persistence();
	
		$filter = new DataFilter("B&uacute;squeda de Tasa de Cambio","cambio");
        
        		
        $ano=date("Y");
        $mes=date("m");
        
        $filter->fechad = new dateonlyField('Desde', 'fechad','d/m/Y');
		$filter->fechah = new dateonlyField('Hasta', 'fechah','d/m/Y');
		$filter->fechah->size=$filter->fechad->size=12;
		$filter->fechah->operator='<=';
        $filter->fechad->insertValue = date("Y-m-d", mktime(0, 0, 0,$mes, 1, $ano));
        $filter->fechah->insertValue = date("Y-m-d");  
		$filter->fechad->clause  =$filter->fechah->clause ='where';
		$filter->fechad->db_name =$filter->fechah->db_name='fecha';
		$filter->fechad->operator='>=';
        
               	
		$filter->buttons("reset","search");
		$filter->build("dataformfiltro");
        
		$uri = anchor("supervisor/cambio/dataedit/show/<#fecha#>","<dbdate_to_human><#fecha#></dbdate_to_human>");
            	        
		$grid = new DataGrid2("Resultado");
		$grid->order_by("fecha","DESC");
		$grid->per_page=10;  
		
        $grid->column("N&uacute;mero"       ,$uri                                            ,"align='center'");
        $grid->column("Venta"               ,"<#cambio#>"                   ,"align='right'");
        $grid->column("Compra"              ,"<#compra#>"                   ,"align='right'");
        $grid->column("Usuario"             ,'usuario'                                         ,"align='center'");
        $grid->column("Fecha de Ingreso"    ,"<#estampa#>"  ,"align='center'");
        
		$grid->add("supervisor/cambio/dataedit/create",'Nuevo Valor');
		$grid->build('datagridST');
		
		
		$extras = '
		<script type="text/javascript">
		//<![CDATA[
		(function() {
			var mySt = new superTable("demoTable", {
			cssSkin : "sSky",
			fixedCols : 1,
			headerRows : 1,
			onStart : function () {	this.start = new Date();},
			onFinish : function () {document.getElementById("testDiv").innerHTML += "Finished...<br>" + ((new Date()) - this.start) + "ms.<br>";}
			});
		})();
		//]]>
		</script>
		';
		
		$style ='
		<style type="text/css">
		.fakeContainer { /* The parent container */
		    margin: 5px;
		    padding: 0px;
		    border: none;
		    width: 1000px; /* Required to set */
		    height: 320px; /* Required to set */
		    overflow: hidden; /* Required to set */
		}
		</style>	
		';

		$data['style']   = $style;
		$data['style']  .= style('superTables.css');

		$data['extras']  = $extras;		
	
		$data['content'] = $grid->output;
		$data['filtro']  = $filter->output;

		$data['title']   = heading("Tasa de Cambio");
		$data['script']  = script('jquery.js');
		$data["script"] .= script('superTables.js');
		$data['head']    = $this->rapyd->get_head();

		$this->load->view('view_ventanas', $data);
	}
     function dataedit(){
		
		$this->rapyd->load("dataedit");				
		$edit = new DataEdit(" ", "cambio");
		
		$edit->back_url = site_url("supervisor/cambio/filteredgrid");
		    
		//echo $abono;
				
		$script ='
		$(function() {
			$(".inputnum").numeric(".");
		});';
		
		$edit->script($script, "create");
		$edit->script($script, "modify");
		
        //$edit->post_process('update','_post_update');
		        
        $edit->usuario  = new autoUpdateField('usuario', $this->session->userdata('usuario'), $this->session->userdata('usuario'));
		        
        $edit->fecha = new DateonlyField('Fecha', 'fecha','d/m/Y');
        $edit->fecha->insertValue = date("Y-m-d");
		$edit->fecha->rule = 'required';
		$edit->fecha->size = 12;
		                      					
        $edit->monto = new inputField("Venta", 'cambio');
        $edit->monto->css_class ='inputnum';
		$edit->monto->size      = 20;
		$edit->monto->rule = 'required';
		
		$edit->compra = new inputField("Compra", 'compra');
        $edit->compra->css_class ='inputnum';
		$edit->compra->size      = 20;
		$edit->compra->rule = 'required';

		$edit->buttons("back","save","modify","undo");
		$edit->build();
        
        $data['content'] =$edit->output;
               
		$data['title']   =  heading("Tasa de Cambio del D&iacute;a");
		$data["head"]    = script("jquery.pack.js").script("plugins/jquery.numeric.pack.js").script("plugins/jquery.floatnumber.js").$this->rapyd->get_head();
		$this->load->view('view_ventanas', $data);
			
	}
	
}
?>
